home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / TexLoadG.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  7.0 KB  |  219 lines

  1. /*
  2.  * (c) Copyright 1995, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * Author: John Spitzer, SGI Applied Engineering
  36.  *
  37.  */
  38.  
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include "FuncEnum.h"
  42. #ifdef WIN32
  43. #include <windows.h>
  44. #endif
  45. #ifdef WIN32
  46. #include <windows.h>
  47. #endif
  48. #include <GL/gl.h>
  49. #include <malloc.h>
  50.  
  51. /* This will be set by compile time #defines                     */
  52. /* They control the size and functionality of the code generated */
  53. #ifdef FULL_FUNCPTR_PATHS
  54.   #define FUNC_PTRS 1
  55. #else
  56.   #define FUNC_PTRS 0
  57. #endif
  58.  
  59. char* pntSuccinct[] = {
  60.     "",
  61.     "Ptr"
  62. };
  63.  
  64. char* objDrawSuccinct[] = {
  65.     "",
  66.     "Point",
  67.     "Tri"
  68. };
  69.  
  70. char* genmapSuccinct[] = {
  71.     "",
  72.     "Map"
  73. };
  74.  
  75. char* miSuccinct[] = {
  76.     "Io",
  77.     "Im"
  78. };
  79.  
  80. char* mlSuccinct[] = {
  81.     "Lo",
  82.     "Lm"
  83. };
  84.  
  85. char* subiSuccinct[] = {
  86.     "Ia",
  87.     "Is"
  88. };
  89.  
  90. char* subtSuccinct[] = {
  91.     "Ta",
  92.     "Ts"
  93. };
  94.  
  95. char* PrintEntry(FILE *fp, int td, int p, int od, int genmap, int mi, int ml, int subi, int subt)
  96. {
  97.     char* funcName = (char*)malloc(64);
  98.     sprintf(funcName,"TexLoad%dD%s%s%s%s%s%s%s",
  99.             td,
  100.             pntSuccinct[p], 
  101.             objDrawSuccinct[od], 
  102.             genmapSuccinct[genmap],
  103.             miSuccinct[mi], 
  104.             mlSuccinct[ml], 
  105.             subiSuccinct[subi], 
  106.             subtSuccinct[subt]
  107.            );
  108.     fprintf(fp,"#define FUNCTION %s\n", funcName);
  109.     if (p)
  110.         fprintf(fp,"#define FUNCTION_PTRS\n");
  111.     if (genmap)
  112.         fprintf(fp,"#define GEN_MIPMAP\n");
  113.     if (subt)
  114.         fprintf(fp,"#define SUBTEXTURE\n");
  115.     if (subi)
  116.         fprintf(fp,"#define SUBIMAGE\n");
  117.     if (mi)
  118.         fprintf(fp,"#define MULTIIMAGE\n");
  119.     if (ml)
  120.         fprintf(fp,"#define MULTILEVEL\n");
  121.     if (od == 1)
  122.         fprintf(fp,"#define POINT_DRAW\n");
  123.     else if (od == 2)
  124.         fprintf(fp,"#define TRI_DRAW\n");
  125.     fprintf(fp,"#define TEX_DIM %d\n", td);
  126.     fprintf(fp,"#include \"TexLoadX.c\"\n");
  127.     fprintf(fp,"#undef FUNCTION\n");
  128.     fprintf(fp,"#undef MULTIIMAGE\n");
  129.     fprintf(fp,"#undef MULTILEVEL\n");
  130.     fprintf(fp,"#undef GEN_MIPMAP\n");
  131.     fprintf(fp,"#undef SUBTEXTURE\n");
  132.     fprintf(fp,"#undef SUBIMAGE\n");
  133.     fprintf(fp,"#undef FUNCTION_PTRS\n");
  134.     fprintf(fp,"#undef POINT_DRAW\n");
  135.     fprintf(fp,"#undef TRI_DRAW\n");
  136.     fprintf(fp,"#undef TEX_DIM\n");
  137.     fprintf(fp,"\n");
  138.     return funcName;
  139. }
  140.  
  141. #define TOTAL_FUNCS 2*2*2*2*2*2*4*4
  142.  
  143. #if defined(GL_SGIS_texture4D)
  144.   #define MAX_TEX_DIM 4
  145. #elif defined (GL_EXT_texture3D)
  146.   #define MAX_TEX_DIM 3
  147. #else
  148.   #define MAX_TEX_DIM 2
  149. #endif
  150.  
  151. #ifdef GL_EXT_subtexture
  152.   #define SUBTEX 1
  153. #else
  154.   #define SUBTEX 0
  155. #endif
  156.  
  157. main()
  158. {
  159.     TexImageLoadFunc function;
  160.     int i;
  161.     int td, p, od, genmap, mi, ml, subi, subt;
  162.     FILE *fp, *header;
  163.     char* names[TOTAL_FUNCS];
  164.  
  165.     for (i=0; i<TOTAL_FUNCS; i++)
  166.         names[i] = "Noop";
  167.     header = fopen("TexLoadX.h", "w");
  168.     fprintf(header, "/*\n * File TexLoadX.h generated from TexLoadG (source file TexLoadG.c)\n */\n\n");
  169.     fp = fopen("TexLoadF.c", "w");
  170.     fprintf(fp, "/*\n * File TexLoadF.c generated from TexLoadG (source file TexLoadG.c)\n */\n\n");
  171.     fprintf(fp, "#include \"Tex.h\"\n");
  172.     for (td=1;td<=MAX_TEX_DIM;td++) {
  173.         for (p=0;p<=FUNC_PTRS;p++) {
  174.             for (od=0;od<3;od++) {
  175.                 for (genmap=0;genmap<2;genmap++) {
  176.                     for (mi=0;mi<2;mi++) {
  177.                         for (ml=0;ml<2;ml++) {
  178.                             for (subi=0;subi<2;subi++) {
  179.                                 for (subt=0;subt<=SUBTEX;subt++) {
  180.                                     if (!(genmap && subt ||
  181.                                           genmap && subi ||
  182.                                           genmap && ml ||
  183.                                           subt && ml ||
  184.                                           subi && ml ||
  185.                       td > 2 && genmap ||
  186.                       td == 4 && subt ||
  187.                       td == 4 && ml
  188.                                        )) {
  189.                                         function.word = 0;
  190.                                         function.bits.texDim  = td-1;
  191.                                         function.bits.functionPtrs  = p;
  192.                                         function.bits.subimage      = subi;
  193.                                         function.bits.subtexture    = subt;
  194.                                         function.bits.multiimage    = mi;
  195.                                         function.bits.multilevel    = ml;
  196.                                         function.bits.genMipmap     = genmap;
  197.                                         function.bits.objDraw       = od;
  198.                                         names[function.word] = PrintEntry(fp, td, p, od, genmap, mi, ml, subi, subt);
  199.                                         fprintf(header, "void %s(TestPtr);\n", names[function.word]);
  200.                                     }
  201.                                 }
  202.                             }
  203.                         }
  204.                     }
  205.                 }
  206.             }
  207.         }
  208.     }
  209.     fclose(fp);
  210.     fprintf(header, "void Noop(TestPtr);\n");
  211.     fprintf(header, "typedef void (*LoadExecuteFunc)(TestPtr);\n");
  212.     fprintf(header, "\nLoadExecuteFunc TexImageLoadExecuteTable[] = {\n");
  213.     for (i=0; i<TOTAL_FUNCS; i++)
  214.         fprintf(header, "    %s,\n", names[i]);
  215.     fprintf(header, "};\n");
  216.     fclose(header);
  217.     return 0;
  218. }
  219.